package com.xunlai.infra.permission.storage.entity;

import lombok.*;
import org.springframework.data.annotation.Id;
import org.springframework.data.relational.core.mapping.MappedCollection;
import org.springframework.data.relational.core.mapping.Table;

import java.io.Serial;
import java.io.Serializable;
import java.util.List;

/**
 * 权限组
 * @author liang
 * @date 2022/11/30 20:37
 */
@Table("system_auth_group")
@Data
@EqualsAndHashCode(callSuper = false)
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class AuthGroup extends BaseEntity implements Serializable {

    @Serial
    private static final long serialVersionUID = -4530702025990718435L;

    @Id
    private Long id ;

    private String instruction;

    private Boolean enable;

    private Short groupType;

    @MappedCollection(idColumn = "group_id")
    private List<AuthGroupCrew> authGroupCrews;

    public enum AuthGroupType{
        PERMISSION_GROUP((short) 1,"权限组"),
        ROLE_MUTEX((short) 2,"角色互斥组"),

        ;

        private final short type;

        private final String desc;

        AuthGroupType(short type, String desc) {
            this.type = type;
            this.desc = desc;
        }

        public short getType() {
            return type;
        }

        public String getDesc() {
            return desc;
        }
    }

}
